#pragma once
#include "RenderTech.h"
#include "..\\Utility\\DirectoryUtil.h"
#include "..\\IO\\XYZFileIO.h"
#include "RenderColorBar.h"
class CRenderHeightMap: public RenderTech
{
public:
	CRenderHeightMap(void);
	virtual ~CRenderHeightMap(void);
	inline CXYZFileIO* GetXYZFile(){return m_pXYZFile;}
	int LoadXYZFile(char* pXYZFileName, float fWidth, float fHeight);
	int LoadXYZFile(CDirectoryUtil* pDirUtil, enum SUBDIRECTORY iSubFolder, TCHAR* pFileName, float fWidth, float fHeight);
	//D3D series functions
	virtual HRESULT OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, CDirectoryUtil* pDirUtil, void* pUserContext );
	virtual HRESULT OnD3D11ResizedSwapChain( ID3D11Device* pd3dDevice, IDXGISwapChain* pSwapChain,
                                         const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, CDirectoryUtil* pDirUtil, void* pUserContext );
	virtual void OnD3D11ReleasingSwapChain( void* pUserContext );
	virtual void OnD3D11DestroyDevice( void* pUserContext );
	virtual void OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, CBaseCamera* pViewCamera, CDirectoryUtil* pDirUtil, double fTime,
                                 float fElapsedTime, void* pUserContext );
	virtual void InitEffectsVariables();
	virtual void ReloadEffectsDebug(ID3D11Device* pd3dDevice, CDirectoryUtil* pDirUtil);
	HRESULT prepareNormalLineVB(ID3D11Device* pd3dDevice);
	HRESULT prepareNormalLineVB1(ID3D11Device* pd3dDevice);
	void RenderNormalLines(ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, CBaseCamera* pViewCamera, CDirectoryUtil* pDirUtil, double fTime,
		float fElapsedTime, void* pUserContext);
	void RenderNormalLines1(ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, CBaseCamera* pViewCamera, CDirectoryUtil* pDirUtil, double fTime,
		float fElapsedTime, void* pUserContext);
	virtual void OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext );
	virtual void AddGUIComp(CDXUTDialog* pControlHud, CDXUTDialog* pControlSampleUI, int iX, int& iY, int iYo, int iWidth, int iHeight);
	virtual void RemoveGUIComp();

private:
	CXYZFileIO* m_pXYZFile;
	bool        m_bDataReady;
	//D3D series members
	ID3D11Buffer*				m_pVB;
	ID3D11Buffer*               m_pIB;
	ID3D11Buffer*               m_pNormalLineVB;
	ID3D11Buffer*               m_pNormalLineVB1;
	//Effect variables
	ID3DX11EffectTechnique*              m_pRenderHeightMapTech;
	ID3DX11EffectTechnique*              m_pRenderHeightMapNormalTech;
	ID3DX11EffectMatrixVariable*         m_pWorldViewProjection;
	ID3DX11EffectScalarVariable*         m_pHeightRange;
	ID3DX11EffectVectorVariable*         m_pNormalDebugColor;
	ID3DX11EffectShaderResourceVariable* m_pColorBarTex;
	ID3D11InputLayout*                   m_pVertexLayout;
	
	//assist
	CRenderColorBar*  m_pColorBar;

	//scaling matrix
	D3DXMATRIX    m_matScaling;

};

